package com.youku.expression;

import com.youku.component.BaseAttribute;

public class Position {

	private String projectId;

	private String suiteId;

	private String caseId;

	private int rowNum = 0;

	public Position() {
		super();
	}

	private Position(String projectId, String suiteId, String caseId) {
		super();
		this.projectId = projectId;
		this.suiteId = suiteId;
		this.caseId = caseId;
	}

	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	public String getSuiteId() {
		return suiteId;
	}

	public void setSuiteId(String suiteId) {
		this.suiteId = suiteId;
	}

	public String getCaseId() {
		return caseId;
	}

	public void setCaseId(String caseId) {
		this.caseId = caseId;
	}

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		if (projectId == null)
			return builder.toString();

		builder.append("项目").append(projectId);

		if (suiteId == null)
			return builder.toString();

		builder.append("=>测试用例组").append(suiteId);

		if (caseId == null)
			return builder.toString();

		builder.append("=>测试用例").append(caseId);

		if (rowNum <= 0)
			return builder.toString();

		builder.append("=>第").append(rowNum).append("行");

		return builder.toString();
	}

	public static Position create(BaseAttribute attribute) {
		return new Position(attribute.getProjectId(), attribute.getSuiteId(), attribute.getCaseId());
	}

	public static Position create(String projectId,String suiteId,String caseId) {
		return new Position(projectId, suiteId, caseId);
	}
}
